﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using CDSBDemandControl.Configuration;

namespace CDSBDemandControlService
{
    public class CDSBNetworkCredentials : Microsoft.TeamFoundation.Client.ICredentialsProvider
    {
        public String UserLogin;
        public String Password;
        public String Domain;
        
        public CDSBNetworkCredentials(CDSBNetWorkUser netWorkUser) 
        {
            this.UserLogin = netWorkUser.UserLogin;
            this.Domain = netWorkUser.UserDomain;
            this.Password = Cryptography.Decrypt(netWorkUser.UserPassWord);
        }
        
        #region ICredentialsProvider Members

        public System.Net.ICredentials GetCredentials(Uri uri, System.Net.ICredentials failedCredentials)
        {


            return new NetworkCredential(this.UserLogin, this.Password, this.Domain);
        }

        public void NotifyCredentialsAuthenticated(Uri uri){}

        #endregion
    }
}
